//
// Created by 冯建涛 on 2023/3/19.
//

#ifndef RTE_TM2831_GUI_TYPE_H
#define RTE_TM2831_GUI_TYPE_H

#include "plc_abi.h"
#include "widget.h"

enum {
    WIDGET_NONE = 0,
    WIDGET_BUTTON,
    WIDGET_LABEL,
    WIDGET_EDIT,
    WIDGET_PROGRESS_BAR,
    WIDGET_SLIDER,
    WIDGET_CHECK_BUTTON,
    WIDGET_RADIO_BUTTON,
    WIDGET_DIALOG,
    WIDGET_WINDOW_MANAGER,
    WIDGET_WINDOW,
    WIDGET_VIEW,
    WIDGET_GROUP_BOX,
    WIDGET_TAB_BUTTON,
    WIDGET_TAB_CONTROL,
    WIDGET_COMBO_BOX,
    WIDGET_COMBO_BOX_ITEM,
    WIDGET_DRAGGER,
    WIDGET_IMAGE,
    WIDGET_IMAGE_ANIMATOR,
    WIDGET_KEYBOARD,
    WIDGET_RICH_TEXT,
    WIDGET_SCROLL_BAR,
    WIDGET_SCROLL_BAR_DESKTOP,
    WIDGET_SCROLL_BAR_MOBILE,
    WIDGET_SCROLL_VIEW,
    WIDGET_SLIDE_VIEW,
    WIDGET_SLIDE_INDICATOR,
    WIDGET_SLIDE_INDICATOR_DESKTOP,
    WIDGET_SLIDE_INDICATOR_MOBILE,
    WIDGET_SLIDE_MENU,
    WIDGET_SLIDE_MENU_DESKTOP,
    WIDGET_SLIDE_MENU_MOBILE,
    WIDGET_COLOR_PICKER,
    WIDGET_COLOR_COMPONENT,
    WIDGET_COLOR_TILE,
    WIDGET_COLOR_TILE_PREV,
    WIDGET_COLOR_TILE_CURRENT,
    WIDGET_COLOR_TILE_PICKER,
    WIDGET_COLOR_MATRIX,
    WIDGET_COLOR_MATRIX_H,
    WIDGET_COLOR_MATRIX_S,
    WIDGET_COLOR_MATRIX_L,
    WIDGET_COLOR_COMPONENT_R,
    WIDGET_COLOR_COMPONENT_G,
    WIDGET_COLOR_COMPONENT_B,
    WIDGET_COLOR_COMPONENT_A,
    WIDGET_COLOR_COMPONENT_H,
    WIDGET_COLOR_COMPONENT_S,
    WIDGET_COLOR_COMPONENT_L,
    WIDGET_COLOR_COMPONENT_HEX,
    WIDGET_COLOR_COMPONENT_RGB,
    WIDGET_COLOR_COMPONENT_HSL,
    WIDGET_COLOR_COMPONENT_ALPHA,
    WIDGET_COLOR_PICKER_BUTTON,
    WIDGET_COLOR_PICKER_DIALOG,
    WIDGET_COLOR_PICKER_CIRCLE,
    WIDGET_COLOR_PICKER_CIRCLE_HSL,
    WIDGET_COLOR_PICKER_CIRCLE_HS,
    WIDGET_COLOR_PICKER_CIRCLE_H,
    WIDGET_COLOR_PICKER_CIRCLE_SV,
    WIDGET_COLOR
};
#define WIDGET_TEXT WIDGET_LABEL
#define WIDGET_NUMBER WIDGET_LABEL
typedef struct {
    u8 type;
    u16 x;
    u16 y;
    u16 w;
    u16 h;
    uint32_t bg_color;
    uint32_t text_color;
    const char *text;
    void *on_button_click;
    void *on_button_up;
    struct _widget_t *handle;

    void (*input)(int val);
} nWidget_t;

typedef struct {
    u16 w;
    u16 h;
    uint32_t bg_color;
    widget_t *handle;
    u8 widget_nrs;
    nWidget_t **widgets;
} nWin_t;

typedef struct {
    u8 win_nrs;
    nWin_t **win;
    u8 current_window;

    void (*set_int)(struct _widget_t *, int);

    void (*set_text_color)(struct _widget_t *, uint32_t);

    int (*get_int)(struct _widget_t *);

    void (*set_text)(struct _widget_t *, const char *);

    void (*set_button_cb_sync)(nWidget_t pWidget, void *pVoid);

    void (*set_button_type)(struct _widget_t *pWidget, int type);

    void (*set_edit_limit)(struct _widget_t *pWidget, int _max, int _min);

    unsigned char (*get_button_value)(struct _widget_t *pWidget);

    void (*set_button_value)(struct _widget_t *pWidget, unsigned char i);
} nGui_t;

extern int hmi_set_win(int winitem);

#endif // RTE_TM2831_GUI_TYPE_H
